package com.example.javaapitest.common;

import com.example.javaapitest.testcase.TxTest;
import org.testng.TestNG;

import java.util.ArrayList;
import java.util.List;

public class RunTestng {
    public static void runClass() throws ClassNotFoundException {
        TestNG testNG = new TestNG();
        Class[] classes = {TxTest.class, Class.forName("com.example.javaapitest.testcase.DenpendTest")};
        testNG.setTestClasses(classes);
        testNG.run();
    }

    public static void runXml() {
        TestNG testNG = new TestNG();
        List<String> suites = new ArrayList<String>();
        suites.add("E:\\aaasrc\\java-api-test\\src\\main\\resources\\testngXml\\testSuite.xml");//此处为xml的绝对路径
        testNG.setTestSuites(suites);
        testNG.run();
    }

    public static void main(String[] args) throws ClassNotFoundException {
        runXml();
        runClass();
    }
}
